/**
 * 模块：医院入驻平台-UserRole
 */
package design.onekey.controller;

import design.onekey.annotation.LoginUser;
import design.onekey.base.BaseEntity;
import design.onekey.base.Response;
import design.onekey.model.dto.UserInfoDto;
import design.onekey.model.UserRole;
import design.onekey.model.dto.UserRoleDto;
import design.onekey.service.IUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @Description: UserRolecontroller类
* @author blcloak
* @date 2020-06-05 04:03:38
* @version V1.0
*/
@RestController
@RequestMapping("/api/userRole")
public class UserRoleController extends BaseController {

   /**
    * iUserRoleService服务注入
    */
   @Autowired
   private IUserRoleService iUserRoleService;

   /**
   * @Description: 分页查询表格
   * @param UserRole
   * @param @return
   * @return BaseEntity
   * @throws
   */
   @RequestMapping(value = "/getTableList",method = RequestMethod.POST)
   public Response getTableList(@RequestBody UserRoleDto model, @LoginUser UserInfoDto userInfoDto)
   {

       BaseEntity result = new BaseEntity();
       result = iUserRoleService.getTableList(model, userInfoDto);
       return Response.success(result);
   }

   /**
   * @Description: 获取详细信息
   * @param id
   * @param @return  BaseEntity
   * @return
   * @throws
   */
   @RequestMapping(value = "/getDetail",method = RequestMethod.GET)
   public Response getDetail(@RequestParam Long id) throws Exception
   {
       BaseEntity result = iUserRoleService.getDetail(id);
       return Response.success(result);
   }

   /**
   * @throws Exception
   * @Description: 新增
   * @param UserRole
   * @return BaseEntity
   * @throws
   */
   @RequestMapping(value = "/insert",method = RequestMethod.POST)
   public Response insert(@RequestBody UserRole model, @LoginUser UserInfoDto userInfoDto) throws Exception
   {
       BaseEntity result = iUserRoleService.insert(model,userInfoDto);
       return Response.success(result.getStatusMsg());
   }

   /**
   * @throws Exception
   * @Description: 更新
   * @param UserRole
   * @return  BaseEntity
   * @throws
   */
   @RequestMapping(value = "/update",method = RequestMethod.POST)
   public Response update(@RequestBody UserRole model, @LoginUser UserInfoDto userInfoDto) throws Exception
   {
       BaseEntity result = iUserRoleService.update(model,userInfoDto);
       return Response.success(result.getStatusMsg());
   }

   /**
   * @Description: 单条删除
   * @param id
   * @return  BaseEntity
   * @throws
   */
   @RequestMapping(value = "/delete",method = RequestMethod.GET)
   public Response delete(@RequestParam Long id)
   {
       BaseEntity result = iUserRoleService.delete(id);
       return Response.success(result.getStatusMsg());
   }

   /**
   * @Description: 批量删除
   * @param UserRole
   * @return BaseEntity
   * @throws
   */
   @RequestMapping(value = "/deletebatch",method = RequestMethod.POST)
   public Response deletebatch(@RequestBody List<Long> ids)
   {
       BaseEntity result = iUserRoleService.deleteBatch(ids);
       return Response.success(result.getStatusMsg());
   }

   /**
    * @Title: getOrgRoles
    * @Description: 获取组织下对应的角色
    * @param userRole
    * @return
    * @author blcloak
    * @date 2020-06-09 06:26:13
    */
   @RequestMapping(value = "/getOrgRoles",method = RequestMethod.POST)
   public Response getOrgRoles(@RequestBody UserRoleDto userRole)
   {
       List<UserRole> result = iUserRoleService.getOrgRoles(userRole);
       return Response.success(result);
   }

   /**
    * @Title: authed
    * @Description: 角色菜单授权
    * @param userRoleDto
    * @return
    * @author blcloak
    * @date 2020-06-11 11:37:42
    */
   @RequestMapping(value = "/authed",method = RequestMethod.POST)
   public Response authed(@RequestBody UserRoleDto userRoleDto, @LoginUser UserInfoDto userInfoDto)
   {
       BaseEntity result = this.iUserRoleService.authed(userRoleDto);
       return Response.success(result.getStatusMsg());

   }
}
